package com.travel.travelServer.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.travel.travelServer.entity.Ticket;
import com.travel.travelServer.mapper.TicketMapper;
import com.travel.travelServer.service.TicketService;
import com.travel.travelServer.utils.BaseService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * (Ticket)表服务实现类
 *
 * @author makejava
 * @since 2024-03-01 15:39:29
 */
@Service("ticketService")
public class TicketServiceImpl extends BaseService<TicketMapper, Ticket> implements TicketService {

    @Override
    public Page<Ticket> page(Page<Ticket> page, Map<String, Object> conditions) {
        LambdaQueryWrapper<Ticket> ticketLambdaQueryWrapper = new LambdaQueryWrapper<>();
        ticketLambdaQueryWrapper.like(Objects.nonNull(conditions.get("name")) && conditions.get("name") != "", Ticket::getName, conditions.get("name"));
        return super.page(page, ticketLambdaQueryWrapper);
    }

    @Override
    public Ticket getById(Long id) {
        return super.getById(id);
    }

    @Override
    public Boolean add(Ticket pojo) {
        return super.save(pojo);
    }

    @Override
    public Boolean update(Ticket pojo) {
        return super.updateById(pojo);
    }

    @Override
    public Boolean removeOne(Long id) {
        return super.removeById(id);
    }

    @Override
    public Boolean batchRemove(List<Long> asList) {
        return super.removeByIds(asList);
    }
}

